from selenium.webdriver.common.by import By
from pages.pages_two.base_page import BasePage

#工作台：添加组件！！！！！！！！！！！！！
class IndexPage(BasePage):
    # 定位器
    tjzj_locator = (By.CSS_SELECTOR,'body > div.container > div.page-header > ul > li:nth-child(2) > a')
    #工作台，添加组件
    assert_locator = (By.CSS_SELECTOR,'#add')
    #添加组件名输入框
    zjsrk_locator = (By.CSS_SELECTOR,'#title')
    #点击保存
    zjbc_locator = (By.CSS_SELECTOR,'#dialog-message > form > div:nth-child(4) > div > input.btn.btn-primary')

    def tjzjan(self):
        self.driver.find_element(*self.tjzj_locator).click()

    def tjzj(self):
        self.driver.find_element(*self.assert_locator).click()
    def mcsrl(self,name):
        self.driver.find_element(*self.zjsrk_locator).send_keys(name)
    def bczj(self):
        self.driver.find_element(*self.zjbc_locator).click()

    #断言工作台，添加组件成功
    gzttjzj_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    def get_gzttjzj(self):
        '''添加组件成功'''
        gzttjzj = self.find_element(self.gzttjzj_locator).text
        return gzttjzj

    #删除工作台、组件???????????
    #定位器
    sczj_locator = (By.CSS_SELECTOR,'body > div.container > div.page-header > ul > li:nth-child(2) > a')
    sczjan_locator = (By.CSS_SELECTOR,'#widgets > div > div.sort-list.ui-sortable > div:nth-child(88) > div > div.dash-title > small > a.delete_sales > i')

    def sczj(self):
        self.driver.find_element(*self.sczj_locator).click()
    def sczjan(self):
        self.driver.find_element(*self.sczjan_locator).click()
        self.driver.switch_to.alert.accept()

    #断言工作台、删除组件成功
    gztsczj_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    def get_gztsczj(self):
        '''工作台删除组件成功'''
        gztsczj = self.find_element(self.gztsczj_locator).text
        return gztsczj















    #发任务！！！！！！！！！！！！！！！！！！！
    #定位器
    frwqz_locator = (By.CSS_SELECTOR, 'body > div.container > div.page-header > ul > li:nth-child(2) > a')
    frw_locator = (By.CSS_SELECTOR,'#calendar > div.c-event-grid > div.c-task-body > div.data-head > a > i')
    zt_locator = (By.CSS_SELECTOR,'#subject')
    fzr_locator = (By.CSS_SELECTOR,'#owner_name')
    fzrqd_locator = (By.CSS_SELECTOR,'#ta1 > span:nth-child(4) > input')
    qdfzr_locator = (By.CSS_SELECTOR,'body > div:nth-child(12) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button:nth-child(1) > span')
    sj_locator = (By.CSS_SELECTOR,'#due_date')
    sjqd_locator = (By.ID,'dpOkInput')
    rwms_locator = (By.XPATH,'/html/body')
    rwbc_locator = (By.CSS_SELECTOR,'body > div.container > div.row-fluid > div > form > table > tfoot > tr > td:nth-child(2) > input:nth-child(1)')

    def frwqz(self):
        self.driver.find_element(*self.tjzj_locator).click()
    def frw(self):
        self.driver.find_element(*self.frw_locator).click()
    def zt(self,zhuti):
        self.driver.find_element(*self.zt_locator).send_keys(zhuti)
    def fzr(self):
        self.driver.find_element(*self.fzr_locator).click()
    def fzrqd(self):
        self.driver.find_element(*self.fzrqd_locator).click()
    def qdfzr(self):
        self.driver.find_element(*self.qdfzr_locator).click()
    def sj(self,rwsj):
        self.driver.find_element(*self.sj_locator).send_keys(rwsj)
    def rwms(self,rwms):
        self.driver.switch_to.frame(0)
        self.driver.find_element(*self.rwms_locator).send_keys(rwms)
        self.driver.switch_to.parent_frame()
    def rwbc(self):
        self.driver.find_element(*self.rwbc_locator).click()

    #断言工作台，发任务成功
    gztfrw_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    def get_gztfrw(self):
        '''发任务成功'''
        gztfrw = self.find_element(self.gztfrw_locator).text
        return gztfrw


    #删除任务
    scrw_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li:nth-child(5) > a')
    scrwan_locator = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(1) > td:nth-child(1) > input')
    scrwqd_locator = (By.CSS_SELECTOR,'#delete')

    def scrw(self):
        self.driver.find_element(*self.scrw_locator).click()
    def scrwan(self):
        self.driver.find_element(*self.scrwan_locator).click()
    def scrwqb(self):
        self.driver.find_element(*self.scrwqd_locator).click()
        self.driver.switch_to.alert.accept()

    #断言工作台，删除任务成功
    gztscrw_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    def get_gztscrw(self):
        '''工作台删除任务成功'''
        gztscrw = self.find_element(self.gztscrw_locator).text
        return gztscrw


    #删除全部任务
    scqbrw_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li:nth-child(5) > a')
    scqbrwan_locator = (By.CSS_SELECTOR,'#control_all')
    scqbqd_locatir = (By.CSS_SELECTOR,'#delete')

    def scqbrw(self):
        self.driver.find_element(*self.scqbrw_locator).click()
    def scqbrwan(self):
        self.driver.find_element(*self.scqbrwan_locator).click()
    def scqbqd(self):
        self.driver.find_element(*self.scqbqd_locatir).click()
        self.driver.switch_to.alert.accept()

    #断言工作台，删除任务成功
    gztscqbrw_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    def get_gztscqbrw(self):
        '''工作台删除任务成功'''
        gztscqbrw = self.find_element(self.gztscrw_locator).text
        return gztscqbrw











    #发日程！！！！！！！！！！！！！！！！！！
    #定位器
    frcqz_locator = (By.CSS_SELECTOR, 'body > div.container > div.page-header > ul > li:nth-child(2) > a')
    frc_locator = (By.CSS_SELECTOR,'#calendar > div.c-event-grid > div.c-event-body > div.data-head > a > i')
    rczt_locator = (By.CSS_SELECTOR,'#subject')
    rcsj_locator = (By.CSS_SELECTOR,'#start_date')
    rcdd_locator = (By.CSS_SELECTOR,'#venue')
    rcjssj_locator = (By.CSS_SELECTOR,'#end_date')
    rcms_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tbody > tr:nth-child(6) > td:nth-child(2) > textarea')
    rcbc_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tfoot > tr > td:nth-child(2) > input:nth-child(1)')

    def frcqz(self):
        self.driver.find_element(*self.tjzj_locator).click()
    def frc(self):
        self.driver.find_element(*self.frc_locator).click()
    def rczt(self,rczhuti):
        self.driver.find_element(*self.rczt_locator).send_keys(rczhuti)
    def rcsj(self,rcsj):
        self.driver.find_element(*self.rcsj_locator).send_keys(rcsj)
    def rcdd(self,rcddnr):
        self.driver.find_element(*self.rcdd_locator).send_keys(rcddnr)
    def rcjssj(self,rcjssj):
        self.driver.find_element(*self.rcjssj_locator).send_keys(rcjssj)
    def rcms(self,rcms):
        self.driver.find_element(*self.rcms_locator).send_keys(rcms)
    def rcbc(self):
        self.driver.find_element(*self.rcbc_locator).click()

    #断言工作台，发日程成功
    gztfrc_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    def get_gztfrc(self):
        '''发日程成功'''
        gztfrc = self.find_element(self.gztfrc_locator).text
        return gztfrc

    #删除日程
    #定位器
    scrc_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li:nth-child(6) > a')
    scrcan_locator = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(1) > td:nth-child(1) > input')
    scrcqd_locator = (By.CSS_SELECTOR,'#delete')

    def scrc(self):
        self.driver.find_element(*self.scrc_locator).click()
    def scrcan(self):
        self.driver.find_element(*self.scrcan_locator).click()
    def scrcqd(self):
        self.driver.find_element(*self.scrcqd_locator).click()
        self.driver.switch_to.alert.accept()

    #断言工作台、删除日程成功
    gztscrc_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    def get_gztscrc(self):
        '''工作台删除日程'''
        gztscrc = self.find_element(self.gztscrc_locator).text
        return gztscrc

    #删除全部日程
    #定位器
    scqbrc_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li:nth-child(6) > a')
    scqbrcan_locator = (By.CSS_SELECTOR,'#check_all')
    scqbrcqd_locator = (By.CSS_SELECTOR,'#delete')

    def scqbrc(self):
        self.driver.find_element(*self.scqbrc_locator).click()
    def scqbrcan(self):
        self.driver.find_element(*self.scqbrcan_locator).click()
    def scqbrcqd(self):
        self.driver.find_element(*self.scqbrcqd_locator).click()
        self.driver.switch_to.alert.accept()

    #断言工作台、删除日程成功
    gztscqbrc_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    def get_gztscqbrc(self):
        '''工作台删除日程'''
        gztscqbrc = self.find_element(self.gztscrc_locator).text
        return gztscqbrc









    #发日志！！！！！！！！！！！！！
    #定位器
    frz_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li.dropdown > a')
    frzqd_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li.dropdown.open > ul > li:nth-child(1) > a')
    rjrz_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div:nth-child(2) > div > a')
    rzbt_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tbody > tr:nth-child(2) > td:nth-child(2) > input')
    xgsj_locator = (By.CSS_SELECTOR,'#business_name')
    xgsjqd_locator = (By.CSS_SELECTOR,'#data > tr > td:nth-child(1) > input[type=radio]:nth-child(1)')
    sjqddj_locator = (By.CSS_SELECTOR,'body > div:nth-child(12) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button:nth-child(1)')
    xgrw_locator = (By.CSS_SELECTOR,'#task_name')
    xgrwdj_locator = (By.CSS_SELECTOR,'#data > tr:nth-child(1) > td:nth-child(1) > input[type=radio]')
    xgrwbc_locator = (By.CSS_SELECTOR,'body > div:nth-child(13) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button:nth-child(1) > span')
    rzms_locator = (By.CSS_SELECTOR,'body')
    frzbc_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tfoot > tr > td:nth-child(2) > input:nth-child(1)')


    def frz(self):
        self.driver.find_element(*self.frz_locator).click()
    def frzqd(self):
        self.driver.find_element(*self.frzqd_locator).click()
    def rjrz(self):
        self.driver.find_element(*self.rjrz_locator).click()
    def rzbt(self,rzbt):
        self.driver.find_element(*self.rzbt_locator).clear()
        self.driver.find_element(*self.rzbt_locator).send_keys(rzbt)
    def xgsj(self):
        self.driver.find_element(*self.xgsj_locator).click()
    def xgsjqb(self):
        self.driver.find_element(*self.xgsjqd_locator).click()
    def sjqddj(self):
        self.driver.find_element(*self.sjqddj_locator).click()
    def xgrw(self):
        self.driver.find_element(*self.xgrw_locator).click()
    def xgrwdj(self):
        self.driver.find_element(*self.xgrwdj_locator).click()
    def xgrwbc(self):
        self.driver.find_element(*self.xgrwbc_locator).click()
    def rzms(self,rzms):
        self.driver.switch_to.frame(0)
        self.driver.find_element(*self.rzms_locator).send_keys(rzms)
        self.driver.switch_to.parent_frame()
    def frzbc(self):
        self.driver.find_element(*self.frzbc_locator).click()

    #断言工作台，发日志成功
    gztfrz_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    def get_gztfrz(self):
        ''''发日志成功'''
        gztfrz = self.find_element(self.gztfrz_locator).text
        return gztfrz

    #删除日志
    #定位器
    scrz_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li.dropdown > a')
    scrzan_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li.dropdown.open > ul > li:nth-child(1) > a')
    scrzdw_locator = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(1) > td:nth-child(1) > input')
    scrzbq_locator = (By.CSS_SELECTOR,'#delete')

    def scrz(self):
        self.driver.find_element(*self.scrz_locator).click()
    def scrzan(self):
        self.driver.find_element(*self.scrzan_locator).click()
    def scrzdw(self):
        self.driver.find_element(*self.scrzdw_locator).click()
    def scrzbq(self):
        self.driver.find_element(*self.scrzbq_locator).click()
        self.driver.switch_to.alert.accept()

    #断言工作台。删除日志成功
    gztscrz_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    def get_gztscrz(self):
        '''工作台删除日志成功'''
        gztscrz = self.find_element(self.gztscrz_locator).text
        return gztscrz

    #删除全部日志
    #定位器
    scqbrz_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li.dropdown > a')
    scqbrzqz_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li.dropdown.open > ul > li:nth-child(1) > a')
    scqbrzan_locator = (By.CSS_SELECTOR,'#check_all')
    scqbrzqd_locator = (By.CSS_SELECTOR,'#delete')

    def scqbrz(self):
        self.driver.find_element(*self.scqbrz_locator).click()
    def scqbrzqz(self):
        self.driver.find_element(*self.scqbrzqz_locator).click()
    def scqbrzan(self):
        self.driver.find_element(*self.scqbrzan_locator).click()
    def scqbrzqd(self):
        self.driver.find_element(*self.scqbrzqd_locator).click()
        self.driver.switch_to.alert.accept()

    #断言工作台。删除日志成功
    gztscqbrz_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    def get_gztscqbrz(self):
        '''工作台删除日志成功'''
        gztscqbrz = self.find_element(self.gztscrz_locator).text
        return gztscqbrz










    #进销存 ，添加产品
    #定位器
    jxccp_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li:nth-child(4) > a')
    jcan_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div:nth-child(2) > div.pull-right > a')
    #产品名称输入框
    cpmc_locator = (By.CSS_SELECTOR,'#name')
    #产品研发时间输入框
    cpsj_locator = (By.CSS_SELECTOR,'#development_time')
    #产品团队输入框
    cptd_locator = (By.CSS_SELECTOR,'#development_team')
    #产品价格输入框
    cpjg_locator = (By.CSS_SELECTOR,'#suggested_price')
    #产品链接输入框
    cplj_locator = (By.CSS_SELECTOR,'#link')
    #产品成本价输入框
    cpcbj_locator = (By.CSS_SELECTOR,'#cost_price')
    #产品图片输入框
    cptp_locator = (By.CSS_SELECTOR,'#main_pic')
    #产品描述
    cpms_locator = (By.CSS_SELECTOR,'#description')
    #产品保存
    cpbc_locator = (By.CSS_SELECTOR,'#form1 > table > tfoot > tr > td > input:nth-child(1)')

    def jxccp(self):
        self.driver.find_element(*self.jxccp_locator ).click()
    def jcan(self):
        self.driver.find_element(*self.jcan_locator).click()
    def cpmc(self,cpmc):
        self.driver.find_element(*self.cpmc_locator).send_keys(cpmc)
    def cpsj(self,cpsj):
        self.driver.find_element(*self.cpsj_locator).send_keys(cpsj)
    def cptd(self,cptd):
        self.driver.find_element(*self.cptd_locator).send_keys(cptd)
    def cpjg(self,cpjg):
        self.driver.find_element(*self.cpjg_locator).send_keys(cpjg)
    def cplj(self,cplj):
        self.driver.find_element(*self.cplj_locator).send_keys(cplj)
    def cpcbj(self,cpcbj):
        self.driver.find_element(*self.cpcbj_locator).send_keys(cpcbj)
    def cptp(self):
        self.driver.find_element(*self.cptp_locator).send_keys(r"C:\Users\LTW\Desktop\th56_p1o\产品图片.png")
    def cpms(self,cpms):
        self.driver.find_element(*self.cpms_locator).send_keys(cpms)
    def cpbc(self):
        self.driver.find_element(*self.cpbc_locator).click()

    #断言进销存添加产品成功
    cpdy_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    def get_cpdy(self):
        ''''产品添加成功'''
        cpdy =self.find_element(self.cpdy_locator).text
        return cpdy

    #删除产品
    #定位器
    sccp_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li:nth-child(4) > a')
    sccpan_locator = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(1) > td:nth-child(1) > input')
    sccpqd_locator = (By.CSS_SELECTOR,'#delete')

    def sccp(self):
        self.driver.find_element(*self.sccp_locator).click()
    def sccpan(self):
        self.driver.find_element(*self.sccpan_locator).click()
    def sccpqd(self):
        self.driver.find_element(*self.sccpqd_locator).click()
        self.driver.switch_to.alert.accept()

    #断言进销存，删除产品成功
    jxcsccp_locator = (By.XPATH,'/html/body/div[5]/div[2]')
    def get_jxcsccp(self):
        ''''进销存删除删除产品成功'''
        jxcsccp = self.find_element(self.jxcsccp_locator).text
        return jxcsccp

    #删除全部产品
    #定位器
    scqbcp_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li:nth-child(4) > a')
    scqbcpan_locator = (By.CSS_SELECTOR,'#check_all')
    scqbcpqd_locator = (By.CSS_SELECTOR,'#delete')

    def scqbcp(self):
        self.driver.find_element(*self.scqbcp_locator).click()
    def scqbcpan(self):
        self.driver.find_element(*self.scqbcpan_locator).click()
    def scqbcpqd(self):
        self.driver.find_element(*self.scqbcpqd_locator).click()
        self.driver.switch_to.alert.accept()

    #断言进销存，删除产品成功
    jxcscqbcp_locator = (By.XPATH,'/html/body/div[5]/div[2]')
    def get_jxcscqbcp(self):
        ''''进销存删除删除产品成功'''
        jxcscqbcp = self.find_element(self.jxcsccp_locator).text
        return jxcscqbcp





    url = "192.168.1.199/crm/index.php?m=dynamic&a=index"

    #断言登录成功！！！！！！！
    username_locator = (By.CSS_SELECTOR,
    'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul.nav.pull-right > li:nth-child(6) > a')

    def get_username(self):
        """获取主页右上角用户名"""
        actul=self.find_element(self.username_locator).text
        return actul


